{% extends "admin/base.html" %}
{% block ext_css %}
    <link href="{{ url_for('static',filename='ext/DataTables-1.10.3/media/css/jquery.dataTables.css') }}"
          rel="stylesheet"
          type="text/css">
{% endblock %}
{% block content %}
    <ol class="breadcrumb">
        <li><a href="#">后台</a></li>
        <li class="active">评论管理</li>
    </ol>
    <hr/>
    <div class="box-header well" data-original-title="">
        <h2><i class="glyphicon glyphicon-book red"></i> 评论管理</h2>
    </div>
    <div class="box-content">
        <table id="user" class="table display table-striped table-bordered  bootstrap-datatable datatable responsive">
            <thead>
            <tr>
                <th>编号</th>
                <th>姓名</th>
                <th>用户</th>
                <th>文章</th>
                <th>父评论</th>
                <th>评论</th>
                <th>审核</th>
                <th>创建时间</th>
                <th>操作</th>
            </tr>
            </thead>
            <tfoot>
            <tr>
                <th>编号</th>
                <th>姓名</th>
                <th>用户</th>
                <th>文章</th>
                <th>父评论</th>
                <th>评论</th>
                <th>审核</th>
                <th>创建时间</th>
                <th>操作</th>
            </tr>
            </tfoot>
            <tbody>
            {% for c in comment %}
                <tr>
                    <td>{{ c.id }}</td>
                    <td>{{ c.name }}</td>
                    <td>{{ c.user_id }}</td>
                    <td>{{ c.article_id }}</td>
                    <td>{{ c.parent_id }}</td>
                    <td>
                        <a tabindex="0" class="label label-default" role="button" data-toggle="popover"
                           data-trigger="focus" title="{{ c.comment }}"
                           data-content="And here's some amazing content. It's very engaging. Right?">{{ c.comment[:10] }}</a>
                    </td>
                    {% if c.disable == 1 %}
                        <td class="center-text">
                            <span class="label label-success">通过</span>
                        </td>
                    {% elif c.disable == 2 %}
                        <td class="center-text">
                            <span class="label label-default">未通过</span>
                        </td>
                    {% else %}
                        <td class="center-text">
                            <span class="label label-warning ">未通过</span>
                        </td>
                    {% endif %}
                    <td class="center">{{ c.timestamp }}</td>
                    <td class="center">
                        <a class="btn btn-success" href="{{ url_for('admin.comment_pass',id=c.id) }}">
                            <i class="glyphicon glyphicon-ok-sign icon-white"></i>
                            通过
                        </a>
                        <a class="btn btn-danger" href="{{ url_for('admin.comment_disable',id=c.id) }}">
                            <i class="glyphicon glyphicon-remove-sign icon-white"></i>
                            不通过
                        </a>
                    </td>
                </tr>
            {% endfor %}
            </tbody>
        </table>
    </div>
{% endblock %}
{% block script %}
    <script type="text/javascript"
            src="{{ url_for('static', filename='ext/DataTables-1.10.3/media/js/jquery.dataTables.js') }}"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $('#user').dataTable({
                stateSave: true
            });
        });
    </script>
{% endblock %}